package com.tx.vuemybatisplusajax.controller;/*
 *
 * @author 陈粒
 * @version 创建时间：2021/8/28 15:45
 */

import com.tx.vuemybatisplusajax.pojo.User;
import com.tx.vuemybatisplusajax.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;
    //插入数据
    @PostMapping("insertuser")
    public String insertuser(@RequestBody User user) {
        userService.insertuser(user);
        return "入库成功";
    }

    //通过id进行删除
    @DeleteMapping("deleteuser")
    public String deletebyid(Integer id) {
        userService.deletebyid(id);
        return "删除成功";
    }
    //通过id进行更新
    @PutMapping("updateuser")
    public String updatebyid(@RequestBody User user){
        userService.updatebyid(user);
        return "修改成功";
    }
    //查询所有数据
    @GetMapping("findall")
    public List<User> findall() {
        return userService.findall();
    }

}
